import 'package:common_utils/common_utils.dart';
import 'package:easy_refresh/easy_refresh.dart';
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:shenfuhui/config/config.dart';
import 'package:shenfuhui/entity/user_info_entity.dart';
import 'package:shenfuhui/provider/userinfo_provider.dart';
import 'package:shenfuhui/utils/user_utils.dart';
import 'package:shenfuhui/views/dialog_manager.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';

import '../http/api.dart';
import '../routers/routers.dart';

class MineCollectProductPage extends StatefulWidget {
  MineCollectProductPage({Key? key}) : super(key: key);

  @override
  State<MineCollectProductPage> createState() => _MineCollectListProductState();
}

class _MineCollectListProductState extends State<MineCollectProductPage> {
  var productList = [];

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    setState(() {
      productList.add('');
      productList.add('');
      productList.add('');
      productList.add('');
      productList.add('');
      productList.add('');
      productList.add('');
      productList.add('');
      productList.add('');
      productList.add('');
      productList.add('');
      productList.add('');
    });
  }

  Widget getProductItem() {
    return Container(
      height: 140.w,
      decoration: BoxDecoration(
          color: Config.colorWhite, borderRadius: BorderRadius.circular(12.w)),
      margin: EdgeInsets.symmetric(horizontal: 25.w, vertical: 11.w),
      child: InkWell(
        onTap: () {
          Routes.router.navigateTo(context, Routes.productDetail,
              transition: TransitionType.inFromRight);
        },
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Container(
              margin: EdgeInsets.only(left: 20.w, right: 20.w),
              child: ClipRRect(
                borderRadius: BorderRadius.circular(5),
                child: Image.network(
                  "https://pic1.zhimg.com/v2-6438843a4cbae9184b935a75a5059ac6_1440w.jpg?source=172ae18b",
                  fit: BoxFit.fill,
                  width: 100.w,
                  height: 100.w,
                ),
              ),
            ),
            Container(
              height: 110.w,
              width: 400.w,
              child: Stack(
                children: [
                  Text(
                    "商品名称",
                    softWrap: true,
                    maxLines: 2,
                    overflow: TextOverflow.ellipsis,
                    style:
                        TextStyle(color: (Config.colorText1), fontSize: 22.w),
                  ),
                  Positioned(
                    bottom: 5.w,
                    child: Text(
                      "￥0.00",
                      softWrap: true,
                      style:
                          TextStyle(color: (Config.colorText1), fontSize: 20.w),
                    ),
                  ),
                ],
              ),
            ),
            Container(
              margin: EdgeInsets.only(left: 0.w),
              width: 140.w,
              height: 46.w,
              child: ElevatedButton(
                clipBehavior: Clip.antiAlias,
                onPressed: () => {
                  // Routes.router.navigateTo(context, Routes.mineAddressEdit,
                  //     transition: TransitionType.inFromRight)
                },
                style: ButtonStyle(
                  elevation: MaterialStateProperty.all(0),
                  backgroundColor: MaterialStateProperty.all(Colors.white),
                  shape: MaterialStateProperty.all(
                    RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(24.w),
                    ),
                  ),
                  side: MaterialStateProperty.all(
                    BorderSide(color: Config.colorText3, width: 2.w),
                  ),
                ),
                child: Text(
                  '取消收藏',
                  style: TextStyle(fontSize: 18.sp, color: Config.colorText3),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      height: 1270.w,
      child: EasyRefresh(
        header: const MaterialHeader(),
        footer: const MaterialFooter(),
        onRefresh: () async {
          await Future.delayed(const Duration(seconds: 1), () {
            print('refresh');
          });
        },
        onLoad: () async {
          await Future.delayed(const Duration(seconds: 1), () {
            print('load');
          });
        },
        child: ListView.builder(
          // shrinkWrap: true,
          // scrollDirection: Axis.vertical,
          // physics: const BouncingScrollPhysics(),
          padding: EdgeInsets.symmetric(vertical: 5.w),
          itemCount: productList.length,
          itemBuilder: (BuildContext context, int index) {
            return getProductItem();
          },
        ),
      ),
    );
  }
}
